package rcos.rpibuckhunter.archersfriend;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.widget.TextView;

public class ScoreReport extends Activity {
	private TextView row1;
	/*private TextView row2;
	private TextView row3;
	private TextView row4;
	private TextView row5;
	private TextView row6;
	private TextView row7;
	private TextView row8;
	private TextView row9;
	private TextView row10;*/
	private TextView row11;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_score_report);
		
		row1 = (TextView) this.findViewById(R.id.textView1);
		/*row2 = (TextView) this.findViewById(R.id.textView2);
		row3 = (TextView) this.findViewById(R.id.textView3);
		row4 = (TextView) this.findViewById(R.id.textView4);
		row5 = (TextView) this.findViewById(R.id.textView5);
		row6 = (TextView) this.findViewById(R.id.textView6);
		row7 = (TextView) this.findViewById(R.id.textView7);
		row8 = (TextView) this.findViewById(R.id.textView8);
		row9 = (TextView) this.findViewById(R.id.textView9);
		row10 = (TextView) this.findViewById(R.id.textView10);*/
		row11 = (TextView) this.findViewById(R.id.textView11);
		
		//String[][] Score = (String[][])getIntent().getSerializableExtra("score_array");
		Bundle b = this.getIntent().getExtras();
		String[] Score = b.getStringArray("score_array");
		
		String r1 = "";
		int r1t = 0;
		/*String r2 = "";
		int r2t = 0;
		String r3 = "";
		int r3t = 0;
		String r4 = "";
		int r4t = 0;
		String r5 = "";
		int r5t = 0;
		String r6 = "";
		int r6t = 0;
		String r7 = "";
		int r7t = 0;
		String r8 = "";
		int r8t = 0;
		String r9 = "";
		int r9t = 0;
		String r10 = "";
		int r10t = 0;*/
		
		for (int foo = 0; foo < 3; foo++) {
			if (Score[foo].equals("X")) {
				r1t += 10;
			}
			else {
				r1t += Integer.parseInt(Score[foo]);
			}
			r1 += Score[foo] + "         ";
		}
		r1 += Integer.toString(r1t);
		row1.setText(r1);
		
		/*for (int foo = 0; foo < 3; foo++) {
			if (Score[1][foo].equals("X")) {
				r2t += 10;
			}
			else {
				r2t += Integer.parseInt(Score[1][foo]);
			}
			r2 += Score[1][foo] + "\t";
		}
		r2 += Integer.toString(r2t);
		row2.setText(r2);
		
		for (int foo = 0; foo < 3; foo++) {
			if (Score[2][foo].equals("X")) {
				r3t += 10;
			}
			else {
				r3t += Integer.parseInt(Score[2][foo]);
			}
			r3 += Score[2][foo] + "\t";
		}
		r3 += Integer.toString(r3t);
		row3.setText(r3);
		
		for (int foo = 0; foo < 3; foo++) {
			if (Score[3][foo].equals("X")) {
				r4t += 10;
			}
			else {
				r4t += Integer.parseInt(Score[3][foo]);
			}
			r4 += Score[3][foo] + "\t";
		}
		r4 += Integer.toString(r4t);
		row4.setText(r4);
		
		for (int foo = 0; foo < 3; foo++) {
			if (Score[4][foo].equals("X")) {
				r5t += 10;
			}
			else {
				r5t += Integer.parseInt(Score[4][foo]);
			}
			r5 += Score[4][foo] + "\t";
		}
		r5 += Integer.toString(r5t);
		row5.setText(r5);
		
		for (int foo = 0; foo < 3; foo++) {
			if (Score[5][foo].equals("X")) {
				r6t += 10;
			}
			else {
				r6t += Integer.parseInt(Score[5][foo]);
			}
			r6 += Score[5][foo] + "\t";
		}
		r6 += Integer.toString(r6t);
		row6.setText(r6);
		
		for (int foo = 0; foo < 3; foo++) {
			if (Score[6][foo].equals("X")) {
				r7t += 10;
			}
			else {
				r7t += Integer.parseInt(Score[6][foo]);
			}
			r7 += Score[6][foo] + "\t";
		}
		r7 += Integer.toString(r7t);
		row7.setText(r7);
		
		for (int foo = 0; foo < 3; foo++) {
			if (Score[7][foo].equals("X")) {
				r8t += 10;
			}
			else {
				r8t += Integer.parseInt(Score[7][foo]);
			}
			r8 += Score[7][foo] + "\t";
		}
		r8 += Integer.toString(r8t);
		row8.setText(r8);
		
		for (int foo = 0; foo < 3; foo++) {
			if (Score[8][foo].equals("X")) {
				r9t += 10;
			}
			else {
				r9t += Integer.parseInt(Score[8][foo]);
			}
			r9 += Score[8][foo] + "\t";
		}
		r9 += Integer.toString(r9t);
		row9.setText(r9);
		
		for (int foo = 0; foo < 3; foo++) {
			if (Score[9][foo].equals("X")) {
				r10t += 10;
			}
			else {
				r10t += Integer.parseInt(Score[9][foo]);
			}
			r10 += Score[9][foo] + "\t";
		}
		r10 += Integer.toString(r10t);
		row10.setText(r10);
		
		int total = r1t+r2t+r3t+r4t+r5t+r6t+r7t+r8t+r9t+r10t;*/
		int total = r1t;
		String r11 = "Total Score:              " + Integer.toString(total);
		row11.setText(r11);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_score_report, menu);
		return true;
	}

}
